package edu.sctu.alex.June.day20150604.threadPractice;

/**
 * Created by user03 on 2015/6/5.
 */
public class Actor extends Thread {

    public void run(){

        System.out.println(getName()+"是个演员");
        int count = 0;
        boolean  is_spectator = true;
        while(is_spectator ){

            System.out.println(getName() + "演出了"+(++count)+"次");
            if(count == 100){
                is_spectator = false;

            }
            if(count%10==0){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }

        }



        System.out.println(getName()+"演出结束");
    }

    public static void main(String[] args) {
        Thread actor = new Actor();
        actor.setName("Mr.Alex");
        actor.run();
        Thread actressThead = new Thread(new Actress(),"Ms.Angelia");
        actressThead.start();

    }

   static class  Actress implements Runnable{


        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName()+"是个演员");
            int count = 0;
            boolean  is_spectator = true;
            while(is_spectator ){

                System.out.println(Thread.currentThread().getName() + "演出了"+(++count)+"次");
                if(count == 100){
                    is_spectator = false;

                }
                if(count%10==0){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }

            }



            System.out.println(Thread.currentThread().getName()+"演出结束");
        }
    }

}
